package com.itgaoshu.springboot_day01.service.impl;

import com.itgaoshu.springboot_day01.bean.User;
import com.itgaoshu.springboot_day01.mapper.UserMapper;
import com.itgaoshu.springboot_day01.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: UserServiceImpl
 * Description:
 * date: 2021/6/30 16:31
 *
 * @author lovegg
 * @since JDK 1.8
 */
@Service
public class UserServiceImpl implements UserService {
   //依赖注入Mapper
    @Autowired
    UserMapper userMapper;

    /**
     *  @Cacheable("selectAllUserList")注解中的selectAllUserList表示：
     *  在redis缓存中开启一个名称为selectAllUserList的缓存区域，缓存区域
     * @return
     */
    //查询用户列表
//    @Cacheable("selectAllUserList")
    @Override
    public List<User> selectUsers(){
        return  userMapper.selectList(null);
    }
    @Override
    public int updateUserById(User user){
        return userMapper.updateById(user);
    }

    @Override
    public User selectUserById(int id) {
        return userMapper.selectById(id);
    }
}
